<nav class="navbar navbar-expand-lg bg-body-tertiary shadow-sm my_navbar">
    <div class="container">
        <a class="navbar-brand d-flex justify-content-start align-items-center" href="{{route('root')}}">
            <img class="d-inline-block align-text-center me-2" width="32" src="{{url('pics/logo/laravel.png')}}" alt="logo" />
            BbsChat
        </a>
        <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
            <span class="navbar-toggler-icon"></span>
        </button>
        <div class="collapse navbar-collapse" id="navbarSupportedContent">
            <ul class="navbar-nav me-auto mb-2 mb-lg-0">
                <li class="nav-item">
                    <a class="nav-link {{active_class(if_route('topics.index'))}}"
                       aria-current="page" href="{{route('topics.index')}}">帖子</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link {{category_navbar_active(1)}}" href="{{route('categories.show',1)}}">文化</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link {{category_navbar_active(2)}}" href="{{route('categories.show',2)}}">体育</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link {{category_navbar_active(3)}}" href="{{route('categories.show',3)}}">旅行</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link {{category_navbar_active(4)}}" href="{{route('categories.show',4)}}">美食</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link {{category_navbar_active(5)}}"  href="{{route('categories.show',5)}}">历史</a>
                </li>

            </ul>
            <ul class="navbar-nav">
                @guest
                    <li class="nav-item">
                        <a class="nav-link"  href="{{route('register')}}">注册</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link"  href="{{route('login')}}">登录</a>
                    </li>
                @else
                    @can('manage_contents')
                        <li class="nav-item d-flex align-items-center">
                            <a href="{{url(config('administrator.uri'))}}"
                               title="进入后台"
                               class="fa-solid fa-gauge text-primary text-decoration-none pe-3">
                            </a>
                        </li>
                    @endcan
                    <li class="nav-item d-flex align-items-center">
                        <a href="{{route('topics.create')}}"
                           title="我要发帖"
                           class="fa-solid fa-plus text-primary text-decoration-none pe-3">
                        </a>
                    </li>
                    <li class="nav-item d-flex align-items-center">
                        <a href="{{route('notifications.index')}}"
                           title="消息通知"
                           class="text-{{Auth::user()->notification_count > 0 ? 'danger' : 'secondary'}} text-decoration-none pe-3 d-flex justify-content-center align-items-center">
                            <i class="fa-solid fa-bell me-1"></i>
                            <span class="badge  text-bg-{{Auth::user()->notification_count > 0 ? 'danger' : 'secondary'}}">
                                {{Auth::user()->notification_count}}
                            </span>
                        </a>
                    </li>
                    <li class="nav-item dropdown">
                        <a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false">
                            @include('shared._avatar',['avatar'=>Auth::user()->avatar,'width'=>40,'is_border'=>'show'])
                            {{Auth::user()->name}}
                        </a>
                        <ul class="dropdown-menu">
                            <li class="text-center">
                                <a class="dropdown-item" href="{{route('users.show',Auth::id())}}">
                                    <i class="fa-solid fa-user-tie"></i>
                                    个人中心
                                </a>
                            </li>
                            <li class="text-center">
                                <a class="dropdown-item" href="{{route('users.edit',Auth::id())}}">
                                    <i class="fa-solid fa-pen-to-square"></i>
                                    编辑资料
                                </a>
                            </li>
                            <li><hr class="dropdown-divider"></li>
                            <li class="text-center">
                                <form action="{{route('logout')}}" method="POST"
                                onsubmit="return confirm('您是否真的要退出登录？')"
                                >
                                    @csrf
                                    <button type="submit" class="btn btn-sm btn-danger">
                                        <i class="fa-solid fa-arrow-right-from-bracket"></i>
                                        退出
                                    </button>
                                </form>
                            </li>
                        </ul>
                    </li>
                @endguest

            </ul>
        </div>
    </div>
</nav>
